module V{
    /** 加载进度面板 */
    export class LoadView extends egret.DisplayObjectContainer{
        /** 进度条 */
        private propress:egret.Shape;
        /** 提示文字 */
        private txt:egret.TextField;
        /** 资源数量 */
        private resNum:number;
        /** 当前的资源 */
        private resC:number;

        public constructor(){
            super();
            this.propress = new egret.Shape();
            this.txt = new egret.TextField();
            this.addChild(this.propress);
            this.txt.size = 18;
            this.addChild(this.txt);
        }
        /** 更新加载进度 */
        public update(c:number, t:number):void{
            if(!this.stage) return;
            if(c == 0){
                this.resC++;
                if(this.resC > this.resNum) return;
            } 
            let wd = this.stage.stageWidth, hd = this.stage.stageHeight;
            this.propress.graphics.clear();
            this.propress.graphics.lineStyle(2, 0x000203, 1);
            this.propress.graphics.drawRoundRect((wd-wd*.8)/2, hd-100, wd*.8, 20, 20, 20);
            this.propress.graphics.endFill();
            this.propress.graphics.beginFill(0x0064b0);
            this.propress.graphics.drawRoundRect((wd-wd*.8)/2, hd-100, wd*.8*(c/t), 20, 20, 20);
            this.propress.graphics.endFill();

            this.txt.text = "正在加载资源"+this.resC+"/"+this.resNum;//console.log(this.txt.text);
            this.txt.y = hd-100+2;
            this.txt.x = wd/2-this.txt.width/2;
        }
        /** 设置资源数量 */
        public setResNum(n:number):void{
            this.resNum = n;
            this.resC = 0;
        }
    }
}